//package cn.flying.cloud;
//
//import javax.annotation.Resource;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.util.Base64;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.UUID;
//
//import org.quartz.Scheduler;
//import org.springframework.boot.ApplicationArguments;
//import org.springframework.boot.ApplicationRunner;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType;
//import org.springframework.http.ResponseEntity;
//import org.springframework.stereotype.Component;
//import org.springframework.web.client.RestTemplate;
//
//import cn.flying.cloud.base.common.utils.Ft;
//import cn.flying.cloud.uid.impl.CachedUidGenerator;
//import cn.flying.cloud.uid.impl.DefaultUidGenerator;
//
///**
// * @author: admin
// * @date: 2025年03月15日 20:58
// * @version: 1.0
// */
//@Component
//public class DemoRunner implements ApplicationRunner {
//
//    @Resource
//    private RestTemplate restTemplate;
//    @Resource
//    private Scheduler scheduler;
//    @Resource
//    private DefaultUidGenerator defaultUidGenerator;
//    @Resource
//    private CachedUidGenerator cachedUidGenerator;
//
//    /**
//     * @param args
//     * @throws Exception
//     */
//    @Override
//    public void run(ApplicationArguments args) throws Exception {
////        String appId = "wxe7fde91399fd3ee3";
////        String appSecret = "8c7171b5fc8e8a288c8fd9cf994baf91";
////        String tokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appId+"&secret=" + appSecret;
////        String rtStr = restTemplate.getForObject(tokenUrl, String.class);
////        System.out.println(rtStr);
////        Map<String, Object> map = Ft.JSON.parseToMap(rtStr);
////        Object accessToken = map.get("access_token");
////        System.out.println(accessToken);
////
////        // 1. 准备请求头，指定Content-Type为JSON
////        HttpHeaders headers = new HttpHeaders();
////        headers.setContentType(MediaType.APPLICATION_JSON);
////
////        // 2. 准备请求体数据（可以是普通Java对象）
////        Map<String, Object> param = new HashMap<>();
////        param.put("service", "wx79ac3de8be320b71");
////        param.put("api", "OcrAllInOne");
////        Map<String, Object> data = new HashMap<>();
////        // img_data	string	是（与img_url二选一）		图片
////        // img_url	string	是（与img_data二选一）		图片
////        File imageFile = new File("D:\\dev\\ocr\\test\\F.jpg");
////        FileInputStream inputStream = new FileInputStream(imageFile);
////        byte[] imageBytes = new byte[(int) imageFile.length()];
////        inputStream.read(imageBytes);
////        String encodeToString = Base64.getEncoder().encodeToString(imageBytes);
////        data.put("img_data", encodeToString);
//////        data.put("img_url", "http://mmbiz.qpic.cn/mmbiz_jpg/7UFjuNbYxibu66xSqsQqKcuoGBZM77HIyibdiczeWibdMeA2XMt5oibWVQMgDibriazJSOibLqZxcO6DVVcZMxDKgeAtbQ/0");
////        // 1：二进制；2：base64字符串；3：图片url
////        data.put("data_type", 2);
////        // 1：身份证；2：银行卡；3：行驶证；4：驾驶证；7：营业执照；8：通用OCR ; 10: 车牌识别
////        data.put("ocr_type", 1);
////        param.put("data", data);
////        param.put("client_msg_id", UUID.randomUUID().toString());
////
////        // 3. 封装请求头和请求体
////        HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(param, headers);
//////        System.out.println("请求参数：");
//////        System.out.println(Ft.JSON.serializer(param));
////        String ocrUrl = "https://api.weixin.qq.com/wxa/servicemarket?access_token=" + accessToken;
////        ResponseEntity<String> entity = restTemplate.postForEntity(ocrUrl, requestEntity, String.class);
////        System.out.println(entity);
////        System.out.println("识别返回：");
////        System.out.println(entity.getBody());
//
////        cacheService.put("aaa", "name", "zhangsan");
////        System.out.println(cacheService.get("aaa", "name"));
////        demoService.method("nick");
//
////        System.out.println(cacheService.get("user", "nick"));
////        System.out.println(999);
//
//
////        // 构建服务实例的 URL
////        String url = "http://localhost:10013/job/run/batch";
////        // 发起 HTTP 请求
////        HttpHeaders headers = new HttpHeaders();
////        headers.add("Accept", "application/json");
////
////        Map<String, Object> body = new HashMap<>();
////        body.put("id", System.currentTimeMillis());
////        body.put("serviceName", "task-server");
////        body.put("jobName", "jobExample");
////        body.put("jobGroup", "DEFAULT");
////        body.put("jobCron", "");
////        body.put("jobDesc", "测试任务");
////        body.put("jobParam", "");
////        body.put("jobStatus", "");
////        body.put("remark", "");
////        body.put("tenantId", "10000");
////
////        HttpEntity<Map<String, Object>> entity = new HttpEntity<>(body, headers);
////        ResponseEntity<Rt> responseEntity = restTemplate.postForEntity(url, entity, Rt.class);
////        Rt rt = responseEntity.getBody();
////        System.out.println("调度结果：" + rt);
//
//        //        defaultUidGenerator.setTimeBits(29);
////        defaultUidGenerator.setWorkerBits(21);
////        defaultUidGenerator.setSeqBits(13);
////        defaultUidGenerator.setEpochStr("2016-05-20");
////        for (int i = 0; i < 20; i++) {
////            System.out.println(defaultUidGenerator.getUID());
////        }
//
////        cachedUidGenerator.setTimeBits(30);
////        cachedUidGenerator.setWorkerBits(27);
////        cachedUidGenerator.setSeqBits(6);
////        cachedUidGenerator.setEpochStr("2016-05-20");
////        for (int i = 0; i < 20; i++) {
////            System.out.println(cachedUidGenerator.getUID());
////        }
//    }
//}
